#include "main/utils.h"
using namespace std;

int maxDiff(const vector<int> &vec) {
  if (vec.size() < 2)
    return -1;

  int smallest = vec[0];
  int max_diff = -1;
  for (int i = 1; i < vec.size(); ++i) {
    auto diff = vec[i] - smallest;
    if (diff > max_diff)
      max_diff = diff;

    if (vec[i] < smallest)
      smallest = vec[i];
  }
  return max_diff;
}

int main() {
  vector<int> vec = {9, 11, 8, 5, 7, 12, 16, 14};
  int ret = maxDiff(vec);
  cout << "The maximum diff is: " << ret << " expected: 11" << endl;

  return 0;
}
